package com.tjbklx1.zk.testcurator;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.retry.RetryNTimes;
import org.apache.curator.retry.RetryUntilElapsed;

public class CreateSession {

	public static void main(String[] args) throws InterruptedException {

		// RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
		// RetryPolicy retryPolicy = new RetryNTimes(5, 1000);
		RetryPolicy retryPolicy = new RetryUntilElapsed(5000, 1000);
		// CuratorFramework client = CuratorFrameworkFactory
		// .newClient("192.168.1.105:2181",5000,5000, retryPolicy);

		CuratorFramework client = CuratorFrameworkFactory.builder()
				.connectString("127.0.0.1:2181")
				.sessionTimeoutMs(5000).connectionTimeoutMs(5000)
				.retryPolicy(retryPolicy).build();
		client.start();
		Thread.sleep(Integer.MAX_VALUE);
	}

}